package Week3.J0501;

import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class 分组_xv {
    static int n, m;
    static Map<Integer,Integer> map = new HashMap<>();


    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        n = scanner.nextInt();
        m = scanner.nextInt();

        int hMax = 0; // 找到最多人的声部
        for (int i = 0; i < n; i++) {
            int x = scanner.nextInt();
            map.put(x, map.getOrDefault(x,0)+1);
            hMax = Math.max(hMax,map.get(x));
        }

        // 边界情况
        int kinds = map.size();
        if (kinds > m) {
            System.out.println(-1);
        }else {
            // 判断最多人数是i时, 能够分组 -> 封装成check函数
            int left = 1;
            int right = hMax;
            while (left < right) {
                int mid = (left + right) / 2;
                if (!check(mid)) {
                    left = mid + 1;
                }else {
                    right = mid;
                }
            }
            System.out.println(left);
//            for (int i = 1; i <= hMax; i++) {
//                if (check(i)) {
//                    System.out.println(i);
//                    break;
//                }
//            }
        }
    }

    private static boolean check(int i) {
        int g = 0;
        for (int x : map.values()) {
            g += x / i + (x % i == 0 ? 0 : 1);
        }
        return g <= m;
    }
}
